/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package redinftel.entidades;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Clase que representa un elemento multimedia
 * en la red social six degrees.
 * @author Six Degrees Team
 */
@Entity
@Table(name = "MULTIMEDIA")
@NamedQueries({
    @NamedQuery(name = "Multimedia.findAll", query = "SELECT m FROM Multimedia m"),
    @NamedQuery(name = "Multimedia.findByIdMultimedia", query = "SELECT m FROM Multimedia m WHERE m.idMultimedia = :idMultimedia"),
    @NamedQuery(name = "Multimedia.findByFecha", query = "SELECT m FROM Multimedia m WHERE m.fecha = :fecha"),
    @NamedQuery(name = "Multimedia.findByTitulo", query = "SELECT m FROM Multimedia m WHERE m.titulo = :titulo"),
    @NamedQuery(name = "Multimedia.findByTipo", query = "SELECT m FROM Multimedia m WHERE m.tipo = :tipo")})
public class Multimedia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_MULTIMEDIA")
    private BigDecimal idMultimedia;
    @Basic(optional = false)
    @Lob
    @Column(name = "IMAGEN")
    private byte[] imagen;
    @Basic(optional = false)
    @Column(name = "FECHA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Column(name = "TITULO")
    private String titulo;
    @Column(name = "NOMBRE")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "TIPO")
    private String tipo;
   @OneToMany(mappedBy = "multimedia")
    private Collection<Perfil> comoPrincipal;
    @JoinColumn(name = "ID_USUARIO", referencedColumnName = "ID_USUARIO")
    @ManyToOne(optional = false)
    private Usuario usuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "multimedia",fetch=FetchType.EAGER)
    private Collection<Comentariomultimedia> comentariomultimediaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "multimedia",fetch=FetchType.EAGER)
    private Collection<Etiquetas> etiquetasCollection;
    @OneToMany(mappedBy = "multimedia")
    private Collection<Publicacion> publicacionCollection;

    public Multimedia() {
    }

    public Multimedia(BigDecimal idMultimedia) {
        this.idMultimedia = idMultimedia;
    }

    public Multimedia(BigDecimal idMultimedia, byte[] imagen, Date fecha, String tipo) {
        this.idMultimedia = idMultimedia;
        this.imagen = imagen;
        this.fecha = fecha;
        this.tipo = tipo;
    }

    public BigDecimal getIdMultimedia() {
        return idMultimedia;
    }

    public void setIdMultimedia(BigDecimal idMultimedia) {
        this.idMultimedia = idMultimedia;
    }

    public byte[] getImagen() {
        return imagen;
    }

    public void setImagen(byte[] imagen) {
        this.imagen = imagen;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public Collection<Comentariomultimedia> getComentariomultimediaCollection() {
        return comentariomultimediaCollection;
    }

    public void setComentariomultimediaCollection(Collection<Comentariomultimedia> comentariomultimediaCollection) {
        this.comentariomultimediaCollection = comentariomultimediaCollection;
    }

    public Collection<Etiquetas> getEtiquetasCollection() {
        return etiquetasCollection;
    }

    public void setEtiquetasCollection(Collection<Etiquetas> etiquetasCollection) {
        this.etiquetasCollection = etiquetasCollection;
    }

    public Collection<Publicacion> getPublicacionCollection() {
        return publicacionCollection;
    }

    public void setPublicacionCollection(Collection<Publicacion> publicacionCollection) {
        this.publicacionCollection = publicacionCollection;
    }

    public Collection<Perfil> getComoPrincipal() {
        return comoPrincipal;
    }

    public void setComoPrincipal(Collection<Perfil> perfilCollection) {
        this.comoPrincipal = perfilCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMultimedia != null ? idMultimedia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Multimedia)) {
            return false;
        }
        Multimedia other = (Multimedia) object;
        if ((this.idMultimedia == null && other.idMultimedia != null) || (this.idMultimedia != null && !this.idMultimedia.equals(other.idMultimedia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "redinftel.entidades.Multimedia[idMultimedia=" + idMultimedia + "]";
    }

}
